package com.gopay.commons.validator.form;

import java.util.Map;

/**
 * 
 * @Form.java
 * @author yaobo
 * @2012-12-26 上午09:57:16 www.gopay.com.cn Inc.All rights reserved.
 */
public class Form {
    /**
     * form name
     */
    private String formName;
    /**
     * 是否POST方式提交
     */
    private boolean postOnly;
    /**
     * FORM继承的FORM
     */
    private String formExtends;
    /**
     * 最终集成的FORM
     */
    private String[] formMulitExtends;
    /**
     * FORM中的验证域
     */
    private Map<String, Field> fields;

    public String getFormName() {
        return formName;
    }

    public void setFormName(String formName) {
        this.formName = formName;
    }

    public boolean isPostOnly() {
        return postOnly;
    }

    public void setPostOnly(boolean postOnly) {
        this.postOnly = postOnly;
    }

    public String getFormExtends() {
        return formExtends;
    }

    public void setFormExtends(String formExtends) {
        this.formExtends = formExtends;
    }

    public Map<String, Field> getFields() {
        return fields;
    }

    public void setFields(Map<String, Field> fields) {
        this.fields = fields;
    }

    public String[] getFormMulitExtends() {
        return formMulitExtends;
    }

    public void setFormMulitExtends(String[] formMulitExtends) {
        this.formMulitExtends = formMulitExtends;
    }

    /**
     * 获取 Field的value属性
     * 
     * @param fieldName
     * @return
     */
    public Object getField(String fieldName) {
        return fields.get(fieldName).getValue();
    }

    /**
     * 设置Field的value属性
     * 
     * @param fieldName
     * @param fieldValue
     */
    public void setField(String fieldName, Object fieldValue) {
        if (fields.get(fieldName) != null) {
            fields.get(fieldName).setValue(fieldValue);
        }
    }
}
